using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Runtime.ConstrainedExecution;
using System.Security;
using System.Globalization;

namespace Win32SDK
{

    [StructLayout(LayoutKind.Sequential)]
    public struct POINTSTRUCT
    {
        public int x;
        public int y;
        public POINTSTRUCT(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
    [Serializable, StructLayout(LayoutKind.Sequential)]
    public struct MSG
    {
        public IntPtr hwnd;
        public int message;
        public IntPtr wParam;
        public IntPtr lParam;
        public int time;
        public int pt_x;
        public int pt_y;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class SIZE
    {
        public int cx;
        public int cy;
        public SIZE()
        {
        }

        public SIZE(int cx, int cy)
        {
            this.cx = cx;
            this.cy = cy;
        }
    }


    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public int left;
        public int top;
        public int right;
        public int bottom;
        public RECT(int left, int top, int right, int bottom)
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }

        public RECT(Rectangle r)
        {
            this.left = r.Left;
            this.top = r.Top;
            this.right = r.Right;
            this.bottom = r.Bottom;
        }

        public static RECT FromXYWH(int x, int y, int width, int height)
        {
            return new RECT(x, y, x + width, y + height);
        }

        public Size Size
        {
            get
            {
                return new Size(this.right - this.left, this.bottom - this.top);
            }
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    public class POINT
    {
        public int x;
        public int y;
        public POINT()
        {
        }

        public POINT(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct PAINTSTRUCT
    {
        public IntPtr hdc;
        public bool fErase;
        public int rcPaint_left;
        public int rcPaint_top;
        public int rcPaint_right;
        public int rcPaint_bottom;
        public bool fRestore;
        public bool fIncUpdate;
        public int reserved1;
        public int reserved2;
        public int reserved3;
        public int reserved4;
        public int reserved5;
        public int reserved6;
        public int reserved7;
        public int reserved8;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class COMRECT
    {
        public int left;
        public int top;
        public int right;
        public int bottom;
        public COMRECT()
        {
        }

        public COMRECT(Rectangle r)
        {
            this.left = r.X;
            this.top = r.Y;
            this.right = r.Right;
            this.bottom = r.Bottom;
        }

        public COMRECT(int left, int top, int right, int bottom)
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }

        public static COMRECT FromXYWH(int x, int y, int width, int height)
        {
            return new COMRECT(x, y, x + width, y + height);
        }

        public override string ToString()
        {
            return string.Concat(new object[] { "Left = ", this.left, " Top ", this.top, " Right = ", this.right, " Bottom = ", this.bottom });
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    public class BITMAP
    {
        public int bmType;
        public int bmWidth;
        public int bmHeight;
        public int bmWidthBytes;
        public short bmPlanes;
        public short bmBitsPixel;
        public IntPtr bmBits = IntPtr.Zero;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class BITMAPINFO
    {
        public int bmiHeader_biSize = 40;
        public int bmiHeader_biWidth;
        public int bmiHeader_biHeight;
        public short bmiHeader_biPlanes;
        public short bmiHeader_biBitCount;
        public int bmiHeader_biCompression;
        public int bmiHeader_biSizeImage;
        public int bmiHeader_biXPelsPerMeter;
        public int bmiHeader_biYPelsPerMeter;
        public int bmiHeader_biClrUsed;
        public int bmiHeader_biClrImportant;
        public byte bmiColors_rgbBlue;
        public byte bmiColors_rgbGreen;
        public byte bmiColors_rgbRed;
        public byte bmiColors_rgbReserved;
        private BITMAPINFO()
        {
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct BITMAPINFO_FLAT
    {
        public int bmiHeader_biSize;
        public int bmiHeader_biWidth;
        public int bmiHeader_biHeight;
        public short bmiHeader_biPlanes;
        public short bmiHeader_biBitCount;
        public int bmiHeader_biCompression;
        public int bmiHeader_biSizeImage;
        public int bmiHeader_biXPelsPerMeter;
        public int bmiHeader_biYPelsPerMeter;
        public int bmiHeader_biClrUsed;
        public int bmiHeader_biClrImportant;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x400)]
        public byte[] bmiColors;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class BITMAPINFOHEADER
    {
        public int biSize = 40;
        public int biWidth;
        public int biHeight;
        public short biPlanes;
        public short biBitCount;
        public int biCompression;
        public int biSizeImage;
        public int biXPelsPerMeter;
        public int biYPelsPerMeter;
        public int biClrUsed;
        public int biClrImportant;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class WNDCLASS_D
    {
        public int style;
        public WndProc lpfnWndProc;
        public int cbClsExtra;
        public int cbWndExtra;
        public IntPtr hInstance = IntPtr.Zero;
        public IntPtr hIcon = IntPtr.Zero;
        public IntPtr hCursor = IntPtr.Zero;
        public IntPtr hbrBackground = IntPtr.Zero;
        public string lpszMenuName;
        public string lpszClassName;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class WNDCLASS_I
    {
        public int style;
        public IntPtr lpfnWndProc = IntPtr.Zero;
        public int cbClsExtra;
        public int cbWndExtra;
        public IntPtr hInstance = IntPtr.Zero;
        public IntPtr hIcon = IntPtr.Zero;
        public IntPtr hCursor = IntPtr.Zero;
        public IntPtr hbrBackground = IntPtr.Zero;
        public IntPtr lpszMenuName = IntPtr.Zero;
        public IntPtr lpszClassName = IntPtr.Zero;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class MENUITEMINFO_T
    {
        public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO_T));
        public int fMask;
        public int fType;
        public int fState;
        public int wID;
        public IntPtr hSubMenu;
        public IntPtr hbmpChecked;
        public IntPtr hbmpUnchecked;
        public IntPtr dwItemData;
        public string dwTypeData;
        public int cch;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class MENUITEMINFO_T_RW
    {
        public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO_T_RW));
        public int fMask;
        public int fType;
        public int fState;
        public int wID;
        public IntPtr hSubMenu = IntPtr.Zero;
        public IntPtr hbmpChecked = IntPtr.Zero;
        public IntPtr hbmpUnchecked = IntPtr.Zero;
        public IntPtr dwItemData = IntPtr.Zero;
        public IntPtr dwTypeData = IntPtr.Zero;
        public int cch;
        public IntPtr hbmpItem = IntPtr.Zero;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class LOGPEN
    {
        public int lopnStyle;
        public int lopnWidth_x;
        public int lopnWidth_y;
        public int lopnColor;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LOGFONT
    {
        public int lfHeight;
        public int lfWidth;
        public int lfEscapement;
        public int lfOrientation;
        public int lfWeight;
        public byte lfItalic;
        public byte lfUnderline;
        public byte lfStrikeOut;
        public byte lfCharSet;
        public byte lfOutPrecision;
        public byte lfClipPrecision;
        public byte lfQuality;
        public byte lfPitchAndFamily;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
        public string lfFaceName;
        public LOGFONT()
        {
        }

        public LOGFONT(LOGFONT lf)
        {
            this.lfHeight = lf.lfHeight;
            this.lfWidth = lf.lfWidth;
            this.lfEscapement = lf.lfEscapement;
            this.lfOrientation = lf.lfOrientation;
            this.lfWeight = lf.lfWeight;
            this.lfItalic = lf.lfItalic;
            this.lfUnderline = lf.lfUnderline;
            this.lfStrikeOut = lf.lfStrikeOut;
            this.lfCharSet = lf.lfCharSet;
            this.lfOutPrecision = lf.lfOutPrecision;
            this.lfClipPrecision = lf.lfClipPrecision;
            this.lfQuality = lf.lfQuality;
            this.lfPitchAndFamily = lf.lfPitchAndFamily;
            this.lfFaceName = lf.lfFaceName;
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    public class LOGBRUSH
    {
        public int lbStyle;
        public int lbColor;
        public IntPtr lbHatch;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVBKIMAGE
    {
        public int ulFlags;
        public IntPtr hBmp = IntPtr.Zero;
        public string pszImage;
        public int cchImageMax;
        public int xOffset;
        public int yOffset;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVCOLUMN
    {
        public int mask;
        public int fmt;
        public int cx;
        public IntPtr pszText;
        public int cchTextMax;
        public int iSubItem;
        public int iImage;
        public int iOrder;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVCOLUMN_T
    {
        public int mask;
        public int fmt;
        public int cx;
        public string pszText;
        public int cchTextMax;
        public int iSubItem;
        public int iImage;
        public int iOrder;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct LVFINDINFO
    {
        public int flags;
        public string psz;
        public IntPtr lParam;
        public int ptX;
        public int ptY;
        public int vkDirection;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class LVGROUP
    {
        public uint cbSize = ((uint)Marshal.SizeOf(typeof(LVGROUP)));
        public uint mask;
        public IntPtr pszHeader;
        public int cchHeader;
        public IntPtr pszFooter = IntPtr.Zero;
        public int cchFooter;
        public int iGroupId;
        public uint stateMask;
        public uint state;
        public uint uAlign;
        public override string ToString()
        {
            return ("LVGROUP: header = " + this.pszHeader.ToString() + ", iGroupId = " + this.iGroupId.ToString(CultureInfo.InvariantCulture));
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVHITTESTINFO
    {
        public int pt_x;
        public int pt_y;
        public int flags;
        public int iItem;
        public int iSubItem;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVINSERTMARK
    {
        public uint cbSize = ((uint)Marshal.SizeOf(typeof(LVINSERTMARK)));
        public int dwFlags;
        public int iItem;
        public int dwReserved;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct LVITEM
    {
        public int mask;
        public int iItem;
        public int iSubItem;
        public int state;
        public int stateMask;
        public string pszText;
        public int cchTextMax;
        public int iImage;
        public IntPtr lParam;
        public int iIndent;
        public int iGroupId;
        public int cColumns;
        public IntPtr puColumns;
        public void Reset()
        {
            this.pszText = null;
            this.mask = 0;
            this.iItem = 0;
            this.iSubItem = 0;
            this.stateMask = 0;
            this.state = 0;
            this.cchTextMax = 0;
            this.iImage = 0;
            this.lParam = IntPtr.Zero;
            this.iIndent = 0;
            this.iGroupId = 0;
            this.cColumns = 0;
            this.puColumns = IntPtr.Zero;
        }

        public override string ToString()
        {
            return ("LVITEM: pszText = " + this.pszText + ", iItem = " + this.iItem.ToString(CultureInfo.InvariantCulture) + ", iSubItem = " + this.iSubItem.ToString(CultureInfo.InvariantCulture) + ", state = " + this.state.ToString(CultureInfo.InvariantCulture) + ", iGroupId = " + this.iGroupId.ToString(CultureInfo.InvariantCulture) + ", cColumns = " + this.cColumns.ToString(CultureInfo.InvariantCulture));
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct LVITEM_NOTEXT
    {
        public int mask;
        public int iItem;
        public int iSubItem;
        public int state;
        public int stateMask;
        public IntPtr pszText;
        public int cchTextMax;
        public int iImage;
        public IntPtr lParam;
        public int iIndent;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class LVTILEVIEWINFO
    {
        public uint cbSize = ((uint)Marshal.SizeOf(typeof(LVTILEVIEWINFO)));
        public int dwMask;
        public int dwFlags;
        public SIZE sizeTile;
        public int cLines;
        public RECT rcLabelMargin;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class SCROLLINFO
    {
        public int cbSize;
        public int fMask;
        public int nMin;
        public int nMax;
        public int nPage;
        public int nPos;
        public int nTrackPos;
        public SCROLLINFO()
        {
            this.cbSize = Marshal.SizeOf(typeof(SCROLLINFO));
        }

        public SCROLLINFO(int mask, int min, int max, int page, int pos)
        {
            this.cbSize = Marshal.SizeOf(typeof(SCROLLINFO));
            this.fMask = mask;
            this.nMin = min;
            this.nMax = max;
            this.nPage = page;
            this.nPos = pos;
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    public class USEROBJECTFLAGS
    {
        public int fInherit;
        public int fReserved;
        public int dwFlags;
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct WINDOWPLACEMENT
    {
        public int length;
        public int flags;
        public int showCmd;
        public int ptMinPosition_x;
        public int ptMinPosition_y;
        public int ptMaxPosition_x;
        public int ptMaxPosition_y;
        public int rcNormalPosition_left;
        public int rcNormalPosition_top;
        public int rcNormalPosition_right;
        public int rcNormalPosition_bottom;
    }
    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public class CHARFORMATA
    {
        public int cbSize = Marshal.SizeOf(typeof(CHARFORMATA));
        public int dwMask;
        public int dwEffects;
        public int yHeight;
        public int yOffset;
        public int crTextColor;
        public byte bCharSet;
        public byte bPitchAndFamily;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
        public byte[] szFaceName = new byte[0x20];
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct NMHDR
    {
        public IntPtr hwndFrom;
        public uint idFrom;
        public uint code;
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct NMSELCHANGE
    {
        public NMHDR nmhdr;
        public SYSTEMTIME stSelStart;
        public SYSTEMTIME stSelEnd;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct SECURITY_ATTRIBUTES
    {
        public UInt32 nLength;
        public IntPtr lpSecurityDescriptor;
        public bool bInheritHandle;
    }


    public delegate void FileIOCompletionRoutine(UInt32 dwErrorCode, UInt32 dwNumberOfBytesTransfered, [In]ref System.Threading.NativeOverlapped lpOverlapped);
    [StructLayout(LayoutKind.Sequential)]
    public struct COMMTIMEOUTS
    {
        public UInt32 ReadIntervalTimeout;
        public UInt32 ReadTotalTimeoutMultiplier;
        public UInt32 ReadTotalTimeoutConstant;
        public UInt32 WriteTotalTimeoutMultiplier;
        public UInt32 WriteTotalTimeoutConstant;
    };
    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public class CHARFORMAT2A
    {
        public int cbSize = Marshal.SizeOf(typeof(CHARFORMAT2A));
        public int dwMask;
        public int dwEffects;
        public int yHeight;
        public int yOffset;
        public int crTextColor;
        public byte bCharSet;
        public byte bPitchAndFamily;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
        public byte[] szFaceName = new byte[0x20];
        public short wWeight;
        public short sSpacing;
        public int crBackColor;
        public int lcid;
        public int dwReserved;
        public short sStyle;
        public short wKerning;
        public byte bUnderlineType;
        public byte bAnimation;
        public byte bRevAuthor;
    }

    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public class CHARFORMATW
    {
        public int cbSize = Marshal.SizeOf(typeof(CHARFORMATW));
        public int dwMask;
        public int dwEffects;
        public int yHeight;
        public int yOffset;
        public int crTextColor;
        public byte bCharSet;
        public byte bPitchAndFamily;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x40)]
        public byte[] szFaceName = new byte[0x40];
    }
    [StructLayout(LayoutKind.Sequential)]
    public class CHARRANGE
    {
        public int cpMin;
        public int cpMax;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class EDITSTREAM
    {
        public IntPtr dwCookie = IntPtr.Zero;
        public int dwError;
        public EditStreamCallback pfnCallback;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class EDITSTREAM64
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
        public byte[] contents = new byte[20];
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct HDLAYOUT
    {
        public IntPtr prc;
        public IntPtr pwpos;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct TBBUTTON
    {
        public int iBitmap;
        public int idCommand;
        public byte fsState;
        public byte fsStyle;
        public byte bReserved0;
        public byte bReserved1;
        public IntPtr dwData;
        public IntPtr iString;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct TBBUTTONINFO
    {
        public int cbSize;
        public int dwMask;
        public int idCommand;
        public int iImage;
        public byte fsState;
        public byte fsStyle;
        public short cx;
        public IntPtr lParam;
        public IntPtr pszText;
        public int cchTest;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct TV_INSERTSTRUCT
    {
        public IntPtr hParent;
        public IntPtr hInsertAfter;
        public int item_mask;
        public IntPtr item_hItem;
        public int item_state;
        public int item_stateMask;
        public IntPtr item_pszText;
        public int item_cchTextMax;
        public int item_iImage;
        public int item_iSelectedImage;
        public int item_cChildren;
        public IntPtr item_lParam;
        public int item_iIntegral;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct TV_ITEM
    {
        public int mask;
        public IntPtr hItem;
        public int state;
        public int stateMask;
        public IntPtr pszText;
        public int cchTextMax;
        public int iImage;
        public int iSelectedImage;
        public int cChildren;
        public IntPtr lParam;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class FINDTEXT
    {
        public CHARRANGE chrg;
        public string lpstrText;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class MCHITTESTINFO
    {
        public int cbSize = Marshal.SizeOf(typeof(MCHITTESTINFO));
        public int pt_x;
        public int pt_y;
        public int uHit;
        public short st_wYear;
        public short st_wMonth;
        public short st_wDayOfWeek;
        public short st_wDay;
        public short st_wHour;
        public short st_wMinute;
        public short st_wSecond;
        public short st_wMilliseconds;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class PARAFORMAT
    {
        public int cbSize = Marshal.SizeOf(typeof(PARAFORMAT));
        public int dwMask;
        public short wNumbering;
        public short wReserved;
        public int dxStartIndent;
        public int dxRightIndent;
        public int dxOffset;
        public short wAlignment;
        public short cTabCount;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
        public int[] rgxTabs;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class REPASTESPECIAL
    {
        public int dwAspect;
        public int dwParam;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class SYSTEMTIME
    {
        public short wYear;
        public short wMonth;
        public short wDayOfWeek;
        public short wDay;
        public short wHour;
        public short wMinute;
        public short wSecond;
        public short wMilliseconds;
        public override string ToString()
        {
            return ("[SYSTEMTIME: " + this.wDay.ToString(CultureInfo.InvariantCulture) + "/" + this.wMonth.ToString(CultureInfo.InvariantCulture) + "/" + this.wYear.ToString(CultureInfo.InvariantCulture) + " " + this.wHour.ToString(CultureInfo.InvariantCulture) + ":" + this.wMinute.ToString(CultureInfo.InvariantCulture) + ":" + this.wSecond.ToString(CultureInfo.InvariantCulture) + "]");
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class SYSTEMTIMEARRAY
    {
        public short wYear1;
        public short wMonth1;
        public short wDayOfWeek1;
        public short wDay1;
        public short wHour1;
        public short wMinute1;
        public short wSecond1;
        public short wMilliseconds1;
        public short wYear2;
        public short wMonth2;
        public short wDayOfWeek2;
        public short wDay2;
        public short wHour2;
        public short wMinute2;
        public short wSecond2;
        public short wMilliseconds2;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class TCITEM_T
    {
        public int mask;
        public int dwState;
        public int dwStateMask;
        public string pszText;
        public int cchTextMax;
        public int iImage;
        public IntPtr lParam;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class TEXTRANGE
    {
        public CHARRANGE chrg;
        public IntPtr lpstrText;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class TOOLINFO_T
    {
        public int cbSize = Marshal.SizeOf(typeof(TOOLINFO_T));
        public int uFlags;
        public IntPtr hwnd;
        public IntPtr uId;
        public RECT rect;
        public IntPtr hinst = IntPtr.Zero;
        public string lpszText;
        public IntPtr lParam = IntPtr.Zero;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class TOOLINFO_TOOLTIP
    {
        public int cbSize = Marshal.SizeOf(typeof(TOOLINFO_TOOLTIP));
        public int uFlags;
        public IntPtr hwnd;
        public IntPtr uId;
        public RECT rect;
        public IntPtr hinst = IntPtr.Zero;
        public IntPtr lpszText;
        public IntPtr lParam = IntPtr.Zero;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class TV_HITTESTINFO
    {
        public int pt_x;
        public int pt_y;
        public int flags;
        public IntPtr hItem = IntPtr.Zero;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class GETTEXTLENGTHEX
    {
        public uint flags;
        public uint codepage;
    }


    [StructLayout(LayoutKind.Sequential)]
    public class NONCLIENTMETRICS
    {
        public int cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS));
        public int iBorderWidth;
        public int iScrollWidth;
        public int iScrollHeight;
        public int iCaptionWidth;
        public int iCaptionHeight;
        [MarshalAs(UnmanagedType.Struct)]
        public LOGFONT lfCaptionFont;
        public int iSmCaptionWidth;
        public int iSmCaptionHeight;
        [MarshalAs(UnmanagedType.Struct)]
        public LOGFONT lfSmCaptionFont;
        public int iMenuWidth;
        public int iMenuHeight;
        [MarshalAs(UnmanagedType.Struct)]
        public LOGFONT lfMenuFont;
        [MarshalAs(UnmanagedType.Struct)]
        public LOGFONT lfStatusFont;
        [MarshalAs(UnmanagedType.Struct)]
        public LOGFONT lfMessageFont;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct HIGHCONTRAST
    {
        public int cbSize;
        public int dwFlags;
        public string lpszDefaultScheme;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct HIGHCONTRAST_I
    {
        public int cbSize;
        public int dwFlags;
        public IntPtr lpszDefaultScheme;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEM_POWER_STATUS
    {
        public byte ACLineStatus;
        public byte BatteryFlag;
        public byte BatteryLifePercent;
        public byte Reserved1;
        public int BatteryLifeTime;
        public int BatteryFullLifeTime;
    }


    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class STARTUPINFO_I
    {
        public int cb;
        public IntPtr lpReserved = IntPtr.Zero;
        public IntPtr lpDesktop = IntPtr.Zero;
        public IntPtr lpTitle = IntPtr.Zero;
        public int dwX;
        public int dwY;
        public int dwXSize;
        public int dwYSize;
        public int dwXCountChars;
        public int dwYCountChars;
        public int dwFillAttribute;
        public int dwFlags;
        public short wShowWindow;
        public short cbReserved2;
        public IntPtr lpReserved2 = IntPtr.Zero;
        public IntPtr hStdInput = IntPtr.Zero;
        public IntPtr hStdOutput = IntPtr.Zero;
        public IntPtr hStdError = IntPtr.Zero;
    }
    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagFONTDESC
    {
        public int cbSizeofstruct = Marshal.SizeOf(typeof(tagFONTDESC));
        [MarshalAs(UnmanagedType.LPWStr)]
        public string lpstrName;
        [MarshalAs(UnmanagedType.U8)]
        public long cySize;
        [MarshalAs(UnmanagedType.U2)]
        public short sWeight;
        [MarshalAs(UnmanagedType.U2)]
        public short sCharset;
        [MarshalAs(UnmanagedType.Bool)]
        public bool fItalic;
        [MarshalAs(UnmanagedType.Bool)]
        public bool fUnderline;
        [MarshalAs(UnmanagedType.Bool)]
        public bool fStrikethrough;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class FONTDESC
    {
        public int cbSizeOfStruct = Marshal.SizeOf(typeof(FONTDESC));
        public string lpstrName;
        public long cySize;
        public short sWeight;
        public short sCharset;
        public bool fItalic;
        public bool fUnderline;
        public bool fStrikethrough;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class PICTDESC
    {
        internal int cbSizeOfStruct;
        public int picType;
        internal IntPtr union1;
        internal int union2;
        internal int union3;
        public static PICTDESC CreateBitmapPICTDESC(IntPtr hbitmap, IntPtr hpal)
        {
            PICTDESC pictdesc = new PICTDESC();
            pictdesc.cbSizeOfStruct = 0x10;
            pictdesc.picType = 1;
            pictdesc.union1 = hbitmap;
            pictdesc.union2 = (int)(((long)hpal) & 0xffffffffL);
            pictdesc.union3 = (int)(((long)hpal) >> 0x20);
            return pictdesc;
        }

        public static PICTDESC CreateIconPICTDESC(IntPtr hicon)
        {
            PICTDESC pictdesc = new PICTDESC();
            pictdesc.cbSizeOfStruct = 12;
            pictdesc.picType = 3;
            pictdesc.union1 = hicon;
            return pictdesc;
        }

        public virtual IntPtr GetHandle()
        {
            return this.union1;
        }

        public virtual IntPtr GetHPal()
        {
            if (this.picType == 1)
            {
                return (IntPtr)(((ulong)this.union2) | (ulong)(this.union3 << 0x20));
            }
            return IntPtr.Zero;
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class OCPFIPARAMS
    {
        public int cbSizeOfStruct = Marshal.SizeOf(typeof(OCPFIPARAMS));
        public IntPtr hwndOwner;
        public int x;
        public int y;
        public string lpszCaption;
        public int cObjects = 1;
        public IntPtr ppUnk;
        public int pageCount = 1;
        public IntPtr uuid;
        public int lcid = System.Windows.Forms.Application.CurrentCulture.LCID;
        public int dispidInitial;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class NOTIFYICONDATA
    {
        public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
        public IntPtr hWnd;
        public int uID;
        public int uFlags;
        public int uCallbackMessage;
        public IntPtr hIcon;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x80)]
        public string szTip;
        public int dwState;
        public int dwStateMask;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
        public string szInfo;
        public int uTimeoutOrVersion;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x40)]
        public string szInfoTitle;
        public int dwInfoFlags;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
    public class PRINTDLG
    {
        public int lStructSize;
        public IntPtr hwndOwner;
        public IntPtr hDevMode;
        public IntPtr hDevNames;
        public IntPtr hDC;
        public int Flags;
        public short nFromPage;
        public short nToPage;
        public short nMinPage;
        public short nMaxPage;
        public short nCopies;
        public IntPtr hInstance;
        public IntPtr lCustData;
        public WndProc lpfnPrintHook;
        public WndProc lpfnSetupHook;
        public string lpPrintTemplateName;
        public string lpSetupTemplateName;
        public IntPtr hPrintTemplate;
        public IntPtr hSetupTemplate;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class PRINTDLGEX
    {
        public int lStructSize;
        public IntPtr hwndOwner;
        public IntPtr hDevMode;
        public IntPtr hDevNames;
        public IntPtr hDC;
        public int Flags;
        public int Flags2;
        public int ExclusionFlags;
        public int nPageRanges;
        public int nMaxPageRanges;
        public IntPtr pageRanges;
        public int nMinPage;
        public int nMaxPage;
        public int nCopies;
        public IntPtr hInstance;
        [MarshalAs(UnmanagedType.LPStr)]
        public string lpPrintTemplateName;
        public WndProc lpCallback;
        public int nPropertyPages;
        public IntPtr lphPropertyPages;
        public int nStartPage;
        public int dwResultAction;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class PAGESETUPDLG
    {
        public int lStructSize;
        public IntPtr hwndOwner;
        public IntPtr hDevMode;
        public IntPtr hDevNames;
        public int Flags;
        public int paperSizeX;
        public int paperSizeY;
        public int minMarginLeft;
        public int minMarginTop;
        public int minMarginRight;
        public int minMarginBottom;
        public int marginLeft;
        public int marginTop;
        public int marginRight;
        public int marginBottom;
        public IntPtr hInstance = IntPtr.Zero;
        public IntPtr lCustData = IntPtr.Zero;
        public WndProc lpfnPageSetupHook;
        public WndProc lpfnPagePaintHook;
        public string lpPageSetupTemplateName;
        public IntPtr hPageSetupTemplate = IntPtr.Zero;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class OPENFILENAME_I
    {
        public int lStructSize = Marshal.SizeOf(typeof(OPENFILENAME_I));
        public IntPtr hwndOwner;
        public IntPtr hInstance;
        public string lpstrFilter;
        public IntPtr lpstrCustomFilter = IntPtr.Zero;
        public int nMaxCustFilter;
        public int nFilterIndex;
        public IntPtr lpstrFile;
        public int nMaxFile = 260;
        public IntPtr lpstrFileTitle = IntPtr.Zero;
        public int nMaxFileTitle = 260;
        public string lpstrInitialDir;
        public string lpstrTitle;
        public int Flags;
        public short nFileOffset;
        public short nFileExtension;
        public string lpstrDefExt;
        public IntPtr lCustData = IntPtr.Zero;
        public WndProc lpfnHook;
        public string lpTemplateName;
        public IntPtr pvReserved = IntPtr.Zero;
        public int dwReserved;
        public int FlagsEx;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct RGNDATAHEADER
    {
        public int cbSizeOfStruct;
        public int iType;
        public int nCount;
        public int nRgnSize;
    }

 

 

    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagSIZE
    {
        public int cx;
        public int cy;
    }
    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagSIZEL
    {
        public int cx;
        public int cy;
    }

    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagLOGPALETTE
    {
        [MarshalAs(UnmanagedType.U2)]
        public short palVersion;
        [MarshalAs(UnmanagedType.U2)]
        public short palNumEntries;
    }
    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagLICINFO
    {
        [MarshalAs(UnmanagedType.U4)]
        public int cbLicInfo = Marshal.SizeOf(typeof(tagLICINFO));
        public int fRuntimeAvailable;
        public int fLicVerified;
    }

    [StructLayout(LayoutKind.Sequential), SuppressUnmanagedCodeSecurity]
    internal class PROCESS_INFORMATION
    {
        public IntPtr hProcess = IntPtr.Zero;
        public IntPtr hThread = IntPtr.Zero;
        public int dwProcessId;
        public int dwThreadId;
        private static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
        ~PROCESS_INFORMATION()
        {
            this.Close();
        }

        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
        internal void Close()
        {
            if ((this.hProcess != IntPtr.Zero) && (this.hProcess != INVALID_HANDLE_VALUE))
            {
                Kernel32.CloseHandle(new HandleRef(this, this.hProcess));
                this.hProcess = INVALID_HANDLE_VALUE;
            }
            if ((this.hThread != IntPtr.Zero) && (this.hThread != INVALID_HANDLE_VALUE))
            {
                Kernel32.CloseHandle(new HandleRef(this, this.hThread));
                this.hThread = INVALID_HANDLE_VALUE;
            }
        }

    }

    [StructLayout(LayoutKind.Sequential)]
    public class STATSTG
    {
        [MarshalAs(UnmanagedType.LPWStr)]
        public string pwcsName;
        public int type;
        [MarshalAs(UnmanagedType.I8)]
        public long cbSize;
        [MarshalAs(UnmanagedType.I8)]
        public long mtime;
        [MarshalAs(UnmanagedType.I8)]
        public long ctime;
        [MarshalAs(UnmanagedType.I8)]
        public long atime;
        [MarshalAs(UnmanagedType.I4)]
        public int grfMode;
        [MarshalAs(UnmanagedType.I4)]
        public int grfLocksSupported;
        public int clsid_data1;
        [MarshalAs(UnmanagedType.I2)]
        public short clsid_data2;
        [MarshalAs(UnmanagedType.I2)]
        public short clsid_data3;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b0;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b1;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b2;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b3;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b4;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b5;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b6;
        [MarshalAs(UnmanagedType.U1)]
        public byte clsid_b7;
        [MarshalAs(UnmanagedType.I4)]
        public int grfStateBits;
        [MarshalAs(UnmanagedType.I4)]
        public int reserved;
    }


    [StructLayout(LayoutKind.Sequential)]
    public class FILETIME
    {
        public int dwLowDateTime;
        public int dwHighDateTime;
    }

    [StructLayout(LayoutKind.Sequential)]
    public sealed class tagOLEVERB
    {
        public int lVerb;
        [MarshalAs(UnmanagedType.LPWStr)]
        public string lpszVerbName;
        [MarshalAs(UnmanagedType.U4)]
        public int fuFlags;
        [MarshalAs(UnmanagedType.U4)]
        public int grfAttribs;
    }

 

 


 



 

 

 


 

 

 

 


 


 


 

 

 

 

 

 

 

 


 

 

 

 


 

 

 


 

 


 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 


 

 

 

 

 


 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
    
 

 

 

 

 

 


 


 

 

 

 

 

 

 


 

 

 

 

 









}//namespace


 

 





